package com.gitee.ywj1352.leecode;

/**
 * 循环队列
 *
 * @author wenjie.yang on 2019/10/12.
 */
public class CircularQueue {

    //queue 存储的大小
    private int n = 0;
    private String[] a;
    private int head;
    private int tail;

    public boolean enqueue(String s) {
        if ((tail + 1) % n == tail) {
            return false;
        }
        a[tail + 1] = s;
        tail = (tail + 1) % n;
        return true;
    }


    public String dequeue(){
        if (tail == head) return null;
        String r = a[head];
        head  = (head -1)%n;
        return r;
    }


}
